package com;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class MyServlet extends HttpServlet {
    //每次访问调用
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置请求乱码
        req.setCharacterEncoding("utf-8");
        //设置响应乱码
        resp.setContentType("text/html;charset=utf-8");

        resp.getWriter().write("臭寄吧菜逼NaNa7mi");
        System.out.println("service调用");
    }
    //关闭时调用
    @Override
    public void destroy() {
        System.out.println("destroy调用");
    }
    //启动时调用1次
    @Override
    public void init() throws ServletException {
        System.out.println("init调用");
    }
}
